package 字符流.作业;

import java.io.*;

public class 使用转换流将格式转换 {
    public static void main(String[] args) throws IOException {
        OutputStreamWriter osw = new OutputStreamWriter/*字符转字节*/(new FileOutputStream("a.txt"), "GBK");
        //创建写
        osw.write("乐呵呵");
        //写入数据
        osw.close();
        //关流

        InputStreamReader isr = new InputStreamReader/*读的格式转换语句*/(new FileInputStream("a.txt"), "GBK");
        //创建读
        int lien;
        while ((lien = isr.read()) != -1) {
            System.out.print((char) lien);
            //输出得到的数据
        }
        isr.close();
        //关流
    }
}
